<?php

namespace app\common\model;

use think\Model;

//评论表
class MarketCommentModel extends Model
{
    //获取评论
    public function getComment($goods_id = '', $page = 10)
    {
        $map = [];
        if (!empty($goods_id)) {
            $map[] = ['goods_id', '=', $goods_id];
        }
        $datas = db('market_comment')
            ->alias('c')
            ->field('c.id,c.msg,c.img,c.time,u.user_nickname,u.avatar')
            ->where($map)
            ->leftJoin('jzb_user u', 'c.uid=u.id')//用户
            ->leftJoin('jzb_market m', 'c.goods_id=m.id')//商品
            ->paginate($page);
        return $datas;
    }
}
